package dao

import javax.inject.Inject
import models.Tables._
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.jdbc.JdbcProfile

import scala.concurrent.{ExecutionContext, Future}

class MtgeneDao@Inject()(protected val dbConfigProvider: DatabaseConfigProvider)(implicit exec:ExecutionContext)
  extends HasDatabaseConfigProvider[JdbcProfile]  {

  import profile.api._

  def insert(row:Seq[MtgeneRow]) : Future[Unit] = {
    db.run(Mtgene ++= row).map(_=>())
  }


  def getMtGeneByGbId(gbid:Int) : Future[Seq[MtgeneRow]] = {
    db.run(Mtgene.filter(_.gbid === gbid).result)
  }

  def getMtGeneById(id:Int) : Future[MtgeneRow] = {
    db.run(Mtgene.filter(_.id === id).result.head)
  }


}
